using Mvc.Mailer;
using ExcellOnServices.Models;
using System.Collections.Generic;

namespace ExcellOnServices.Mailers
{ 
    public class Mailer : MailerBase, IMailer 	
	{
		public Mailer()
		{
            MasterName = "_MyLayout";
		}
		
		public virtual MvcMailMessage ActiveCompanyAccMail(Accounts_Company acc, string passwordNotEncrypted)
		{
            var mailMessage = new MvcMailMessage { Subject = "Your Account at Excell-On Store" };

            mailMessage.To.Add(acc.Account.Email);
            ViewBag.Account =acc;
            ViewBag.Password = passwordNotEncrypted;

            PopulateBody(mailMessage, viewName: "ActiveCompanyAccMail");
            return mailMessage;
		}

        public virtual MvcMailMessage ConfirmOrderMail(Order order)
        {
            var mailMessage = new MvcMailMessage { Subject = "Confirm your order from Excell-On Service"};

            ICollection<OrderItem> orItems = order.OrderItems;
            string mailCompany = "";
            ViewBag.CompanyName = "";
            foreach (OrderItem item in orItems)
            {
                mailCompany = item.Product.Accounts_Company.Account.Email;
                ViewBag.CompanyName = item.Product.Accounts_Company.BrandName;
                break;
            }
            ViewBag.Order = order;
            mailMessage.To.Add(mailCompany);

            PopulateBody(mailMessage, viewName: "ConfirmOrderMail");
            return mailMessage;
        }
 	}
}